package com.example.spring.service;

import com.example.spring.Dto.AddressCount;
import com.example.spring.Dto.Company;
import com.example.spring.Dto.CompanyCountDTO;
import com.example.spring.Dto.CompanyTypeCount;
import com.example.spring.mapper.CompanyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyService {

    @Autowired
    private CompanyMapper companyMapper;

    public List<Company> getValidCompanies(int limit) {
        return companyMapper.selectValidCompanies(limit);
    }

    public List<AddressCount> getAddressCounts() {
        return companyMapper.getAddressCounts();
    }

    public List<CompanyTypeCount> getTopCompanyTypeCounts() {
        return companyMapper.getTopCompanyTypeCounts();
    }


    public Long getCompanyCount() {
        CompanyCountDTO countDTO = companyMapper.getCompanyCount();
        return countDTO != null ? countDTO.getCount() : 0L;
    }

}
